<!DOCTYPE html>
<html>
<head>
	<title>{{ title if title else "Saviors of Middle Earth" }}</title>
	<link rel="icon" type="image/png" href="/images/logo.png"/>
	{%macro js(src)%}<script src="/js/{{src}}.js" type="text/javascript"></script>{%endmacro%}
	{%macro css(href)%}<link rel="stylesheet" type="text/css" media="all" href="/css/{{href}}.css"/>{%endmacro%}
	{%block javascript%}
	{{js('timezone')}}
	{{js('search-keyboard-shortcut')}}
	{{js('forms')}}
	{%if flash%}{{js('flash')}}{%endif%}
	{%if current_user and not current_user.deactivated%}
	<script type="text/javascript" src="/_ah/channel/jsapi"></script>
	{{js('messaging')}}
	{%endif%}
	{%endblock%}
	{%block stylesheets%}
	{{css('base')}}
	{%endblock%}
</head>
<body{%if current_user%} data-channel-token="{{channel_token}}" data-csrf-token="{{csrf_token}}" data-current-user="{{current_user.key().id()}}"{%endif%}{%if user %} data-page-user="{{user.key().id()}}"{%endif%}>
	{%macro csrf_field()%}<input type="hidden" name="csrf_token" value="{{csrf_token}}"/>{%endmacro%}
	<div id="header">
		<a href="/" class="homepage-link"></a>
		<div class="parent">
			<div class="title">
				<div class="branding">Saviors of Middle Earth</div>
				<div class="subtitle">{{title if title else ""}}</div>
			</div>
			<form class="search-field" action="/search" method="get">
				<input type="search" id="search-field" autocomplete="off" placeholder="Search" name="q" title="Keyboard Shortcut: Ctrl-Alt-F" value="{{q|default}}"/>
			</form>
		</div>
	</div>
	{%if flash%}
	<div id="flash">
		<div class="close-button">x</div>
		<div class="message">{{flash}}</div>
	</div>
	{%endif%}
	<div id="content">
		{% block content %}{% endblock %}
	</div>
	<footer id="copyright">
		&copy; Wes Kendrick, Marc Rosen, and William Zhang 2013
	</footer>
{#This goes at the bottom so that it is at the highest z index#}
	<div id="user-panel" class="{{'loggedin' if current_user else 'guest'}}">
		{% if current_user %}
		<div class="profilepic" style="background-image:url('{{current_user|url(action='thumbnail')}}')">
			<a class="highlight" href="{{current_user|url}}"></a>
		</div>
		<a href="{{current_user|url}}">My Items</a>
		{%if current_user.admin%}<a href="/admin">Admin</a>{%endif%}
		<a href="{{ '/'|logout_url }}">Logout</a>
		<div class="nickname">{{current_user.nickname}}</div>
		{% else %}
		<a href="{{ path|login_url }}">Login</a>
		{% endif %}
	</div>
	{%if current_user%}
	<div id="messages-panel">
		<div class="messages-opener{%if current_user.has_unread_messages%} attn{%endif%}">
			Messages
		</div>
		<div class="contents">
			<div class="sidebar"></div>
			<div class="main-pane">
				<div class="title"></div>
				<div class="messages"></div>
				<textarea></textarea>
				<div class="overlay">
					<div class="loading">Loading...</div>
				</div>
			</div>
		</div>
		<div class="template" data-name="message-group">
			<div class="user">
				<a class="pic" href="#" target="_blank"></a>
				<div class="name">Joey</div>
				<div class="time">TIME</div>
			</div>
			<div class="clearer"></div>
		</div>
	</div>
	{%endif%}
</body>
</html>